﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Rotempco.BaseClass;
using Rotempco.BaseClass.Objects.EntityObjects;
using Rotempco.BaseClass.Objects.Enums;
using Rotempco.Core.Web.Logic;
using Rotempco.BaseClass.Managers;

namespace Rotempco.Website.WebPages.Admin.Users
{
    public partial class ResetPassword : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                long loginUserId = UrlLogic.GetParameterAsLong("Id").Value;
                LoginUser loginUser = Factory.LoginUser.GetById(loginUserId);

                Literal_UserName.Text = loginUser.Name;
            }
        }

        protected bool userControl_EditBottomPanel_OnSaveEvent()
        {
            long loginUserId = UrlLogic.GetParameterAsLong("Id").Value;
            LoginUser loginUser = Factory.LoginUser.GetById(loginUserId);

            ResetPasswordResultEnum resetPasswordResultEnum = Factory.LoginUser.ResetPassword(loginUser.Email);

            switch (resetPasswordResultEnum)
            {
                case ResetPasswordResultEnum.Success:
                    Response.Redirect("Default.aspx");
                    break;
                case ResetPasswordResultEnum.LoginUserNotFound:
                case ResetPasswordResultEnum.EncryptionKeyError:
                default:

                    break;
            }


            return false;
        }
    }
}